﻿/***********************************************************************************************************************************
 *    Name: Delete_MDW.sql
 *  Author: Frank Figearo — http://www.sqlnerd.me/ — frank@sqlnerd.me
 * Summary: 
**/

SELECT tsql_command= N'DROP PROCEDURE [' + SCHEMA_NAME(schema_id) + N'].[' + name + N'];' FROM sys.objects WHERE schema_id <> 1 AND type = 'P'
UNION ALL
SELECT tsql_command= N'DROP FUNCTION  [' + SCHEMA_NAME(schema_id) + N'].[' + name + N'];' FROM sys.objects WHERE schema_id <> 1 AND type IN ('FN','IF','TF')
UNION ALL
SELECT tsql_command= N'DROP VIEW      [' + SCHEMA_NAME(schema_id) + N'].[' + name + N'];' FROM sys.objects WHERE schema_id <> 1 AND type = 'V'
UNION ALL
SELECT tsql_command= N'DROP TABLE     [' + SCHEMA_NAME(schema_id) + N'].[' + name + N'];' FROM sys.objects WHERE schema_id <> 1 AND type = 'U';
GO